#ifndef TCP_H
#define TCP_H


#include <QMainWindow>
#include<QtNetwork/QTcpServer>
#include<QtNetwork/QTcpSocket>
#include<QtNetwork/QHostAddress>
#include<QObject>
#include<QDebug>


namespace Ui {
class tcp;
}

class tcp : public QObject
{
        Q_OBJECT
public:
  explicit tcp(QObject *parent = nullptr);
    ~tcp();
    QString extractIPv4FromQHostAddress(QHostAddress &address);
   // QString ipv4;
    QTcpSocket* socket;    // TCP通信的socket


private:
    Ui::tcp *ui;
    QString name;
    QTcpServer *sv;
    QString ipv4;


signals:
    void dataReceived(const QString &data,QString name); // 声明一个信号

    private slots:
    void newConnect_handler();



};



#endif // TCP_H
